import request from '@/utils/request'
import type { ITrademarkData, ITrademark } from './types'

enum API {
  TRADEMARK_URL = '/admin/product/baseTrademark/', // 获取品牌 分页列表
  ADD_TRADEMARK_URL = '/admin/product/baseTrademark/save', // 新增品牌
  DELETE_TRADEMARK_URL = '/admin/product/remove/', // 删除品牌
  UPDATE_TRADEMARK_URL = '/admin/product/update/' // 修改品牌
}

export const reqHasTrademark = (page: number = 1, limit: number = 3) => {
  return request.get<any, Common<ITrademarkData>>(API.TRADEMARK_URL + `${page}/${limit}`)
}

export const reqAddOrUpdateTrademark = (data: ITrademark) => {
  if (data.id) {
    return request.put(API.UPDATE_TRADEMARK_URL, data)
  } else {
    return request.post<any, any>(API.ADD_TRADEMARK_URL, data)
  }
}

export const reqDeleteTrademark = (id: number) => request.delete<any, Common<null>>(API.DELETE_TRADEMARK_URL + `${id}`)
